<template>
	<view class="content">

		<view class="formBox">
			<view class="title">基本信息</view>
			<!-- <view class="f-c-fs item" v-for="(item,index) in items.list" :key="index">
				<view class="label">{{ item.name }}：</view>
				<view class="value">{{ item.value }}</view>
			</view> -->
			<view class="f-c-fs item"  v-for="(item,key,index) in detail" v-if="key!='goods'" :key="index" >
				<view class="label">{{ key}}：</view>
				<view class="value">{{item}}</view>
			</view>
		</view>
		<view v-if="detail.goods&&detail.goods.length>0" class="formBox">
			<view class="title">核销商品/项目</view>
			<view class="item" v-for="(item,index) in detail.goods" :key="index">
				<view class="f-c-fs item">
					<view class="label">名称：</view>
					<view class="value">{{ item.shoppingServiceName }}</view>
				</view>
				<view class="f-c-sb">
					<view v-if="item.price" class="f-c-fs">
						<view class="label">单价：</view>
						<view class="value">￥{{ item.price }}</view>
					</view>
					<view class="f-c-fs">
						<view class="label">核销数量：</view>
						<view class="value">{{ item.number }}</view>
					</view>
				</view>

			</view>

		</view>
	</view>
</template>

<script>
	import {
		writeoffLogInfo
	} from '@/api/marketingB-helper.js';

	export default {
		data() {
			return {
				id: '4',
				detail: {}
			};
		},
		onLoad(option) {
			console.log(option)
			if (option.param) {
				this.id = JSON.parse(option.param).id
				this.getDetail()
			}
		},
		methods: {
			getDetail() {
				writeoffLogInfo({
					id: this.id
				}).then(res => {
					if (res.code == 200) {
						this.detail = res.data
						if (!this.detail.goods || this.detail.goods.length == 0) {
							delete this.detail.goods
						}
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			}
		}
	};
</script>

<style lang="less" scoped>
	.content {
		width: 100%;
		min-height: 100vh;
		background: #f5f5f5;

		.formBox {
			padding: 22rpx;

			.item {
				margin: 15rpx 0;
				.label{
					min-width: 150rpx;
				}
			}
		}
	}
</style>
